package cn.yy.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Client entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "client", catalog = "phoneerp")
public class Client implements java.io.Serializable {

	// Fields

	private Integer clientId;
	private Area area;
	private Matirialtype matirialtype;
	private String clientName;
	private Integer clientType;
	private Integer clientTel;
	private String clientAddress;
	private Integer clientBillId;
	private Set<Sale> sales = new HashSet<Sale>(0);
	private Set<Bonus> bonuses = new HashSet<Bonus>(0);
	private Set<Recipt> recipts = new HashSet<Recipt>(0);

	// Constructors

	/** default constructor */
	public Client() {
	}

	/** minimal constructor */
	public Client(Area area, Matirialtype matirialtype, String clientName,
			Integer clientType, Integer clientTel, String clientAddress,
			Integer clientBillId) {
		this.area = area;
		this.matirialtype = matirialtype;
		this.clientName = clientName;
		this.clientType = clientType;
		this.clientTel = clientTel;
		this.clientAddress = clientAddress;
		this.clientBillId = clientBillId;
	}

	/** full constructor */
	public Client(Area area, Matirialtype matirialtype, String clientName,
			Integer clientType, Integer clientTel, String clientAddress,
			Integer clientBillId, Set<Sale> sales, Set<Bonus> bonuses,
			Set<Recipt> recipts) {
		this.area = area;
		this.matirialtype = matirialtype;
		this.clientName = clientName;
		this.clientType = clientType;
		this.clientTel = clientTel;
		this.clientAddress = clientAddress;
		this.clientBillId = clientBillId;
		this.sales = sales;
		this.bonuses = bonuses;
		this.recipts = recipts;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "clientId", unique = true, nullable = false)
	public Integer getClientId() {
		return this.clientId;
	}

	public void setClientId(Integer clientId) {
		this.clientId = clientId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "areaId", nullable = false)
	public Area getArea() {
		return this.area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "clientProductTypeId", nullable = false)
	public Matirialtype getMatirialtype() {
		return this.matirialtype;
	}

	public void setMatirialtype(Matirialtype matirialtype) {
		this.matirialtype = matirialtype;
	}

	@Column(name = "clientName", nullable = false, length = 10)
	public String getClientName() {
		return this.clientName;
	}

	public void setClientName(String clientName) {
		this.clientName = clientName;
	}

	@Column(name = "clientType", nullable = false)
	public Integer getClientType() {
		return this.clientType;
	}

	public void setClientType(Integer clientType) {
		this.clientType = clientType;
	}

	@Column(name = "clientTel", nullable = false)
	public Integer getClientTel() {
		return this.clientTel;
	}

	public void setClientTel(Integer clientTel) {
		this.clientTel = clientTel;
	}

	@Column(name = "clientAddress", nullable = false, length = 20)
	public String getClientAddress() {
		return this.clientAddress;
	}

	public void setClientAddress(String clientAddress) {
		this.clientAddress = clientAddress;
	}

	@Column(name = "clientBillID", nullable = false)
	public Integer getClientBillId() {
		return this.clientBillId;
	}

	public void setClientBillId(Integer clientBillId) {
		this.clientBillId = clientBillId;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
	public Set<Sale> getSales() {
		return this.sales;
	}

	public void setSales(Set<Sale> sales) {
		this.sales = sales;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
	public Set<Bonus> getBonuses() {
		return this.bonuses;
	}

	public void setBonuses(Set<Bonus> bonuses) {
		this.bonuses = bonuses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
	public Set<Recipt> getRecipts() {
		return this.recipts;
	}

	public void setRecipts(Set<Recipt> recipts) {
		this.recipts = recipts;
	}

}